﻿@model LeEdu.MODEL.Group

@{
    ViewBag.Title = "TeamMember";
    Layout = "~/Views/Shared/_Index.cshtml";

}
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<div id="content-container" class="container">
    <div class="group-header">
        <div class="group-header-inner" style="background: url(http://localhost:5130/Img/@Model.GBACKGROUND); background-repeat: no-repeat; background-size: 100% 100%; ">
            <div class="media">
                <div class="media-left">
                    <a href="/Group/GroupHomepage/@Model.GroupID">
                        <img src="http://localhost:5130/Img/@Model.GLOGO" alt="@Model.GNAME" class="avatar-square-sm">
                    </a>
                </div>
                <div class="media-body">
                    <h2 class="media-heading">@Model.GNAME</h2>
                    <input type="hidden" value="@Model.GroupID" id="groupid" />
                    <div class="media-metas">
                        @ViewBag.Count 个成员
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-body">
            <ul class="nav nav-tabs">
                <li><a href="/Group/GroupHomepage/@Model.GroupID">小组首页</a></li>
                <li class="active"><a href="/Group/TeamMember/@Model.GroupID">小组成员</a></li>
                @*@if (Session["User"] != null)
                {
                    if ((ViewBag.ZU as LeEdu.MODEL.UserAndGroup).UserInfoID == (Session["User"] as LeEdu.MODEL.UserInfo).UserInfoId)
                    {*@
                        <li><a href="/Group/GroupSetting/@Model.GroupID">小组设置</a></li>
                    @*}
                }*@
               
                <li><a href="/Group/HuaTiCreate" target="blank">发表话题</a></li>
            </ul>
            <h4 class="mtl">组长</h4>
            <div class="clearfix">

                <div class="grouplist" style="width: 38px;">
                    <a href="#" title="xijiguo">
                        <img src="http://localhost:5130/Img/@((ViewBag.ZU as LeEdu.MODEL.UserAndGroup ).Users.Avatar)" alt="" class="avatar-sm">
                    </a>
                    <p class="text-center">
                        <a class="link-light" href="#" title="@((ViewBag.ZU as LeEdu.MODEL.UserAndGroup).UserInfoID )">@((ViewBag.ZU as LeEdu.MODEL.UserAndGroup).Users.Uname)</a>
                    </p>
                </div>



            </div>
            <h4 class="mtl">副组长</h4>
            <div class="clearfix">
                <form action="/Group/RemoveZu/@Model.GroupID" method="post" id="admin-form">

                    @if (ViewBag.FU.Count != 0)
                    {
                        if (Session["User"] != null)
                        {


                            if ((ViewBag.ZU as LeEdu.MODEL.UserAndGroup).UserInfoID == (Session["User"] as LeEdu.MODEL.UserInfo).UserInfoId)
                            {
                                <button id="remove-admin-btn" type="submit" class="btn btn-default btn-sm pull-right">撤消副组长</button>

                                foreach (var item in ViewBag.FU as List<LeEdu.MODEL.UserAndGroup>)
                                {

                                    <div class="grouplist" style="width: 58px;margin-left:20px;float:left">
                                        <a href="#" title="xijiguo">
                                            <img src="http://localhost:5130/Img/@item.Users.Avatar" alt="" class="avatar-sm">
                                        </a>
                                        <p class="text-center">
                                            <a class="link-light" style="margin-left:-20px;" href="#" title="@item.Users.UserInfoId">@item.Users.Uname</a>
                                        </p>
                                        <input value="@item.UserInfoID" style="margin-left:10px;" name="FUZU" class="checkboxs" type="checkbox">   <br>
                                    </div>
                                }

                            }
                            else { 
                                  foreach (var item in ViewBag.FU as List<LeEdu.MODEL.UserAndGroup>)
                            {

                                <div class="grouplist" style="width: 58px;margin-left:20px;float:left">
                                    <a href="#" title="xijiguo">
                                        <img src="http://localhost:5130/Img/@item.Users.Avatar" alt="" class="avatar-sm">
                                    </a>
                                    <p class="text-center">
                                        <a class="link-light" style="margin-left:-20px;" href="#" title="@item.Users.UserInfoId">@item.Users.Uname</a>
                                    </p>

                                </div>
                            }
                          
                            }
                        }
                        else
                        {
                            foreach (var item in ViewBag.FU as List<LeEdu.MODEL.UserAndGroup>)
                            {

                                <div class="grouplist" style="width: 58px;margin-left:20px;float:left">
                                    <a href="#" title="xijiguo">
                                        <img src="http://localhost:5130/Img/@item.Users.Avatar" alt="" class="avatar-sm">
                                    </a>
                                    <p class="text-center">
                                        <a class="link-light" style="margin-left:-20px;" href="#" title="@item.Users.UserInfoId">@item.Users.Uname</a>
                                    </p>
                                </div>
                            }
                        }
                    }
                    else
                    {
                        <p class="text-muted">还没有副组长！</p>
                    }

                </form>
            </div>

            @if (ViewBag.YUAN.Count != 0)
            {
                if (Session["User"] != null)
                {
                    if ((ViewBag.ZU as LeEdu.MODEL.UserAndGroup).UserInfoID == (Session["User"] as LeEdu.MODEL.UserInfo).UserInfoId)
                    {
                        <div class="btn-group pull-right">
                            <button id="delete-btn" type="button" class="btn btn-default btn-sm">踢出成员</button>
                            <button id="set-admin-btn" type="button" class="btn btn-default btn-sm ">设置副组长</button>
                        </div>
                    }
                }
            }
            
            <form action="/Group/EditZU/@Model.GroupID" method="post" id="member-form" class="clearfix">
                <h4 class="mtl">组员</h4>
                <div>
                    @if (ViewBag.YUAN.Count != 0)
                    {
                        foreach (var item in ViewBag.YUAN as List<LeEdu.MODEL.UserAndGroup>)
                        {
                            <div class="grouplist" style="width: 58px;margin-left:20px;float:left">
                                <a href="#" title="@item.Users.Uname">
                                    <img src="http://localhost:5130/Img/@item.Users.Avatar" alt="" class="avatar-sm">
                                </a>
                                <p class="text-center">
                                    <a class="link-light" style="margin-left:-20px;" href="#" title="@item.Users.UserInfoId">@item.Users.Uname</a>
                                </p>
                                @if (Session["User"] != null)
                                {
                                if ((ViewBag.ZU as LeEdu.MODEL.UserAndGroup).UserInfoID == (Session["User"] as LeEdu.MODEL.UserInfo).UserInfoId)
                                {
                                <input value="@item.UserInfoID" style="margin-left:10px;" name="ZUYUAN" class="checkboxs" type="checkbox"> 
                                }
                                }  <br>
                            </div>
                        }
                    }
                    else
                    {
                        <p class="text-muted">还没有小组成员！！</p>
                    }
                </div>
            </form>
            <nav class="text-center">
            </nav>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("#remove-admin-btn").click(function () {
            if ($(" #admin-form  input:checked").length < 1) {
                alert('请选择要设置的成员！')
                return false;
            } else {
                if (confirm('是否撤销副组长！') == false) {
                    return false;
                }
            }

        })

        $("#delete-btn").click(function () {
            if ($("#member-form  input:checked").length < 1) {
                alert('请选择要设置的成员！')
                return false
            }
            else {
                if (confirm('是否踢出此成员！') == false) {
                    return false;
                }
                else {
                    var IDlist = [];
                    IDlist.push("0");
                    $(":checked[name=ZUYUAN]").each(function () {
                        IDlist.push(this.value);
                    })

                    location.href = "/Group/DelZU/@Model.GroupID?str=" + IDlist.toString();

                }
            }
        })

        $("#set-admin-btn").click(function () {
            if ($("#member-form input:checked").length < 1) {
                alert('请选择要设置的成员！')
                return false
            }
            else {
                if (confirm('是否设置为副组长！') == false) {
                    return false;
                }
                else {
                    var IDlist = [];
                    IDlist.push("0");
                    $(":checked[name=ZUYUAN]").each(function () {
                        IDlist.push(this.value);
                    })

                    location.href = "/Group/EditZU/@Model.GroupID?str=" + IDlist.toString();
                }
            }
        })
    })

</script>